#!/usr/bin/env bash

echo "=======使用变量======="
your_name="qinjx"
echo $your_name
echo ${your_name}


echo "====变量名外面的花括号是可选的===="
for skill in Ada Coffe Action Java; do
    echo "I am good at ${skill}Script"
done

echo "====只读变量===="
myUrl="http://www.google.com"
readonly myUrl
#myUrl="http://www.runoob.com" 错误的

echo "====删除变量===="
myUrl1="http://www.runoob.com"
unset myUrl1
echo $myUrl1

echo "====拼接字符串===="
your_name="runoob"
# 使用双引号拼接
greeting="hello, "$your_name" !"
greeting_1="hello, ${your_name} !"
echo $greeting  $greeting_1
# 使用单引号拼接
greeting_2='hello, '$your_name' !'
greeting_3='hello, ${your_name} !'
echo $greeting_2  $greeting_3

echo "====获取字符串长度===="
string="abcd"
echo ${#string} #输出 4

echo "====提取子字符串===="
string="runoob is a great site"
echo ${string:1:4} # 输出 unoo

echo "====查找子字符串===="
string="runoob is a great site"
echo `expr index "$string" io`  # 输出 4


